# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=mosquito
pkgver=39.fe54831
pkgrel=5
groups=('blackarch' 'blackarch-exploitation' 'blackarch-webapp')
pkgdesc='XSS exploitation tool - access victims through HTTP proxy.'
arch=('any')
url='https://github.com/koto/mosquito'
license=('custom:unknown')
depends=('python2' 'python2-simplejson' 'python2-lxml' 'python2-urwid'
         'python2-pyopenssl' 'python2-pyasn1' 'python2-pyasn1-modules'
         'python2-flask' 'python2-jsbeautifier')
makedepends=('git')
source=("git+https://github.com/koto/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  git submodule update --init --recursive
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname/start.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

